<template>
  <custom-container class="finance-report">
    <custom-container-header no-spacing>
      <el-form :model="filters" ref="form" :disabled="loading"
               inline size="medium"
               @submit.native.prevent="getAll"
               class="width-100"
      >
        <el-form-item label="查询时间:">
          <el-date-picker
            v-model="filters.date"
            type="daterange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="{disabledDate: beforeToday.disabledDate}"
            value-format="timestamp"
            :default-time="['00:00:00', '23:59:59']"
          >
          </el-date-picker>
        </el-form-item>

        <el-form-item label="会员账户：">
          <el-input v-model="filters.username" auto-complete="off"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" native-type="submit">查询</el-button>
        </el-form-item>

        <el-form-item class="float-right" v-show="false">
          <custom-button-group v-model="time">
            <custom-button v-for="period in periods" :key="period.value" :label="period.value">
              {{period.title}}
            </custom-button>
          </custom-button-group>
        </el-form-item>
      </el-form>
    </custom-container-header>
    <custom-container-body>
      <el-table :data="tableData.list" :loading="loading" element-loading-text="加载中..." border border-radius

                @sort-change="sortChange"
      >
        <el-table-column
          align="center"
          prop="userName"
          label="用户名">
        </el-table-column>

        <el-table-column
          align="center"
          prop="amount"
          label="首存金额">
          <template slot-scope="{row}">
            {{row.amount | currency}}
          </template>
        </el-table-column>

        <el-table-column
          align="center"
          prop="tradeType"
          label="首存类型">
        </el-table-column>

        <el-table-column
          align="center"
          prop="timestamp"
          label="首存时间">
          <template slot-scope="{row}">
            {{row.timestamp | toTime}}
          </template>
        </el-table-column>

        <el-table-column
          align="center"
          prop="tradeNo"
          label="交易编号">
        </el-table-column>

        <template slot="empty">
          <div class="el-table__empty">
            <svg-icon class="el-table__empty-icon" icon-class="grid-empty-2"></svg-icon>
            <div class="el-table-text">暂无数据</div>
          </div>
        </template>
      </el-table>

      <div class="el-pagination-container">
        <el-pagination
          bordered
          @size-change="gridSizeChange" @current-change="gridCurrentChange"
          :current-page="filters.page" :page-size="filters.size"
          :total="tableData.total">
        </el-pagination>
      </div>
    </custom-container-body>
  </custom-container>
</template>

<script type="text/jsx">

  import {
    firstRechargeApi as getApi,
  } from '@/services/api/report';

  import {grid, pickerOption} from '@/build';

  export default {
    name: "game-win-lose",

    mixins: [grid, pickerOption],

    data() {
      return {
        filters: {
          date: undefined,
          page: 1,
          size: 10,
        },
        time: consts.THIS_WEEK,
        periods: _.filter(consts.TIME_PERIOD, (period) => {
          return _.indexOf([consts.THIS_WEEK, consts.LAST_WEEK, consts.THIS_MONTH, consts.LAST_MONTH], period.value) !== -1;
        }),
        tableData: {
          list: [],
          total: 0,
        }
      };
    },

    mounted() {
      this.bindGet(getApi, 'tableData', {
        action: 'getGrid',
        sendingData: 'filters',
      });
    }
  };

</script>

